package com.example.dto;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import org.springframework.security.oauth2.server.authorization.settings.OAuth2TokenFormat;

import java.io.IOException;

public class OAuth2TokenFormatSerializer extends JsonSerializer<OAuth2TokenFormat> {

    @Override
    public void serialize(OAuth2TokenFormat value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
        if (value != null) {
            gen.writeString(value.getValue()); // 将 OAuth2TokenFormat 转换为字符串
        } else {
            gen.writeNull();
        }
    }
}